home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_08
/
8n08070a
< prev
next >
Wrap
Text File
|
1990-07-17
|
737b
|
36 lines
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define ARRAY_SIZE 1000
int test_array[ARRAY_SIZE];
int compare(int *a,int *b)
{
return(*a-*b);
}
main()
{
int i;
time_t start_time;
time_t stop_time;
for ( i=0 ; i<ARRAY_SIZE ; i++ )
test_array[i] = rand();
time( &start_time );
qsort( test_array, ARRAY_SIZE, sizeof(int), compare );
time( &stop_time );
printf( "%f seconds elapsed.\n",
difftime(stop_time,start_time) );
for ( i=0; i<ARRAY_SIZE-1 ; i++ )
if ( test_array[i] > test_array[i+1] )
printf( "Mismatch at position %d\n", i );
}
A Driver Program to Test Quicksort Performance